/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "GEOFT_DNAEE_BACIA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Bacia.findAll", query = "SELECT b FROM Bacia b"),
    @NamedQuery(name = "Bacia.findByDnbCd", query = "SELECT b FROM Bacia b WHERE b.dnbCd = :dnbCd"),
    @NamedQuery(name = "Bacia.findByDnbNm", query = "SELECT b FROM Bacia b WHERE b.dnbNm = :dnbNm"),
    @NamedQuery(name = "Bacia.findByDnbGmPoligono", query = "SELECT b FROM Bacia b WHERE b.dnbGmPoligono = :dnbGmPoligono")})
public class Bacia implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "DNB_CD")
    private BigDecimal dnbCd;
    @Size(max = 100)
    @Column(name = "DNB_NM")
    private String dnbNm;
    @Size(max = 4000)
    @Column(name = "DNB_GM_POLIGONO")
    private String dnbGmPoligono;
    @OneToMany(mappedBy = "dnbCd")
    private List<Subbacia> subbaciaList;

    /**
     *
     */
    public Bacia() {
    }

    /**
     *
     * @param dnbCd
     */
    public Bacia(BigDecimal dnbCd) {
        this.dnbCd = dnbCd;
    }

    /**
     *
     * @return
     */
    public BigDecimal getDnbCd() {
        return dnbCd;
    }

    /**
     *
     * @param dnbCd
     */
    public void setDnbCd(BigDecimal dnbCd) {
        this.dnbCd = dnbCd;
    }

    /**
     *
     * @return
     */
    public String getDnbNm() {
        return dnbNm;
    }

    /**
     *
     * @param dnbNm
     */
    public void setDnbNm(String dnbNm) {
        this.dnbNm = dnbNm;
    }

    /**
     *
     * @return
     */
    public String getDnbGmPoligono() {
        return dnbGmPoligono;
    }

    /**
     *
     * @param dnbGmPoligono
     */
    public void setDnbGmPoligono(String dnbGmPoligono) {
        this.dnbGmPoligono = dnbGmPoligono;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Subbacia> getSubbaciaList() {
        return subbaciaList;
    }

    /**
     *
     * @param subbaciaList
     */
    public void setSubbaciaList(List<Subbacia> subbaciaList) {
        this.subbaciaList = subbaciaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dnbCd != null ? dnbCd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bacia)) {
            return false;
        }
        Bacia other = (Bacia) object;
        if ((this.dnbCd == null && other.dnbCd != null) || (this.dnbCd != null && !this.dnbCd.equals(other.dnbCd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return " " + this.dnbCd +" - "+ this.dnbNm;
    }
    
}
